package com.woniuxy.dao;

import com.woniuxy.model.MenuModel;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author 马世亮
 * @since 2022-02-15
 */
public interface MenuModelDao extends BaseMapper<MenuModel> {

    @Select("SELECT\n" +
            "            DISTINCT\n" +
            "            mm.menu_id menu_id,\n" +
            "            mm.menu_name menu_name,\n" +
            "            mm.menu_icon menu_icon,\n" +
            "            mm.menu_router menu_router,\n" +
            "            mm.menu_isleafnode menu_isleafnode,\n" +
            "            mm.menu_parent_id menu_parent_id\n" +
            "        FROM account_role ar\n" +
            "        JOIN\n" +
            "            menu_role mr ON ar.role_id=mr.role_id\n" +
            "        JOIN\n" +
            "            menu_model mm ON mr.menu_id=mm.menu_id\n" +
            "        WHERE ar.account_id=#{accountId}")
    public List<MenuModel> selectMenusByAccountId(Integer accountId);
}
